package com.qcrud.core.type;

import java.sql.Clob;
import java.sql.ResultSet;
import java.sql.SQLException;

public class ClobTypeHandler implements TypeHandler<String> {

    @Override
    public String getResult(ResultSet rs, int columnIndex) throws SQLException {
        Clob clob = rs.getClob(columnIndex);
        return toString(clob);
    }

    private String toString(Clob clob) throws SQLException {
        return clob == null ? null : clob.getSubString(1, (int) clob.length());
    }
}
